package com.whz.gateway.common.constants;

import com.whz.generic.Constants;
import lombok.experimental.UtilityClass;

/**
 * @author whz
 */
@UtilityClass
public class GatewayConstant {

    public static final int MAX_BYTE_SIZE = 50 * 1024 * 1024;

    public static final String IMAGE_KEY = "tongyu:gateway:image:key:";

    //========================
    /**
     * 生成图片验证码
     */
    public static final String IMAGE_CODE_PATH = "/image/code";
    /**
     * 校验图片验证码
     */
    public static final String IMAGE_CODE_CHECK = "/image/check";

    /**
     * 验证码缓存key
     */
    public static final String IMAGE_PARAM_T = "t";
    /**
     * 用户输入的验证码
     */
    public static final String IMAGE_PARAM_CODE = "code";

    //========================
    public static final String SMS_SEND_PATH = "/sms/code";
    public static final String SMS_CHECK_PATH = "/sms/check";
    public static final String SMS_PARAM_PHONE = "phone";
    public static final String SMS_PARAM_CODE = "code";

    //========================
    /**
     * 服务降级路径
     */
    public static final String FALL_BACK_PATH = "/fallback";
    /**
     * swagger resource path
     */
    public static final String SWAGGER_PATH = "/v3/api-docs";

    /**
     * gateway`s white list path
     */
    public static final String[] WHITE_LIST_PATHS = {
            // swagger
            "/swagger-ui/**",
            "/swagger-resources/**",
            "/*" + SWAGGER_PATH,
            SWAGGER_PATH,

            // phone code
            "/*/sms/**",
            // websocket
            "/*/change-manager",

            // image code
            IMAGE_CODE_PATH,
            IMAGE_CODE_CHECK,

            // health check
            "/actuator/**",

            // oauth2
            "/*/oauth/**",

            // user login
            "/*/tongyu/logout",
            "/*/tongyu/login",

            // public接口
            "/public/**",
            "/*/public/**",

            // static resource
            "/**/css/**",
            "/**/js/**",
            "/**/images/**",
            "/**/*.css",
            "/**/*.js",
            "/**/favicon.ico",
            "/favicon.ico",
    };

    /**
     * 黑名单
     */
    public static final String[] BLACK_LIST_PATHS = new String[]{
            // private 路径禁止外网访问
            "/private/**",
            "/*/private/**"
    };

    public static final String[] SWAGGER_BLACK_LIST_PATHS = new String[]{
            // private 路径禁止外网访问
            "/swagger/**",
            "/actuator/**",
            "/v2/api-docs"
    };

    public static final String[] PROTECTED_LIST_PATHS = new String[]{
            // 需要登录,不需要鉴权
            "/protected/**",
            "/*/protected/**",
            "/protect/**",
            "/*/protect/**"
    };


    // GATEWAY下传的header
    public static final String X_USER_ID = Constants.X_USER_ID;
    public static final String X_USER_NAME = Constants.X_USER_NAME;
    public static final String X_COMPANY_ID = Constants.X_COMPANY_ID;
    public static final String X_COMPANY_NAME = Constants.X_COMPANY_NAME;
    public static final String X_DEPARTMENT_ID = Constants.X_DEPARTMENT_ID;
    public static final String X_DEPARTMENT_NAME = Constants.X_DEPARTMENT_NAME;
    public static final String X_PRODUCT_ID = Constants.X_PRODUCT_ID;
    public static final String X_PRODUCT_NAME = Constants.X_PRODUCT_NAME;
    public static final String X_TEMP_USER_FLAG = Constants.X_TEMP_USER_FLAG;
    public static final String X_TEMP_USER_FLAG_VALUE = Constants.X_TEMP_USER_FLAG + "-VALUE";


    /**
     * 用户详情
     */
    public static final String USER_DETAILS_ATTRIBUTE = "X_SCG_USER_DETAIL_ATTRIBUTE";
    /**
     * 命中白名单
     */
    public static final String USER_WHITE_LIST_ATTRIBUTE = "X_SCG_WHITE_LIST_NOT_AUTHORIZATION";
}